import { defineStore } from 'pinia'
import { ApiRes } from '@/types/data'
import { GoodsInfo } from '@/types/goods'
import request from '@/utils/request'

// export const useGoodsStore = defineStore('goods',{

// })

export const useGoodsStore = defineStore({
  id: 'goods',
  state: () => {
    return {
      goodsInfo: {} as GoodsInfo
    }
  },
  actions: {
    async getGoodsInfo (id: string) {
      const res = await request.get<ApiRes<GoodsInfo>>(`/goods?id=${id}`)

      this.goodsInfo = res.data.result
    }
  }
})
